<?php
include_once("../../config.php");
$plate=select_one_line_all_items($table_Prefix."plate","mid = 'equipment'");
?>

<?php include "../../coresection/checkSession.php";?>
<?php include "../../coresection/admin-product.php";?>
<?php include "../../coresection/order-list.php";?>

<?
//用来判断当前系统属于什么板块
$system_part = $plate['mid'];
include_once("detail-function.php");
?>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <?php include '../../modules/head.php'; ?>
</head>

<body>


<style>
    .content  { background-color:#ffffff!important}
    .content ul { overflow: hidden; margin-bottom: 25px; width: 910px;}
    .content ul li{ float: left; width:300px;;}
</style>


<?php include '../../modules/topbar.php'; ?>

<div class="setup_area">


    <?php include '../../modules/sidebar-admin.php'; ?>

    <div class="header">
        <h1> 设备统计 </h1>

        <?php include '../../modules/header.php'; ?>

    </div>


    <div class="content_area dishes_box">



<div class="detail-box equipment-detail-static-box layui-form">


    <div class="layui-form">


<div class="content">

    <?
    $rental=select_one_line_all_items($table_Prefix."rental","status = '借出' and equipmentid = '".$detail['equipmentid']."' order by borrowdate desc");

    $employee=select_one_line_all_items($table_Prefix."employee","nid = '".$rental['borrower']."'");

    ?>

<ul>
    <li>设备:<? echo $detail['name']?></li>
    <li>购买日期:<? echo $detail['buydate']?></li>
    <li>牌子:<? echo $detail['brand']?></li>

    <?
    $department=select_one_line_all_items($table_Prefix."department","nid = '".$detail['departmentid']."'");
    ?>


    <li>所属部门:<? echo $department['name']?></li>


    <li>状态:<? echo $detail['status']?></li>

    <li>备注:<? echo $detail['remark']?></li>

</ul>
</div>




        <table class="layui-table">
            <colgroup>
                <col width="80">
                <col width="200">
                <col >
                <col>
            </colgroup>
            <thead>
            <tr>
                <th>序号</th>
                <th>项目</th>
                <th>统计</th>
                <th>金额</th>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td>1</td>
                <td>维修次数</td>
                <td><?echo count_by_item($table_Prefix."repair","equipmentid='".$trans_nid."'")?></td>
                <td><?echo sum_total($table_Prefix."repair","cost","equipmentid='".$trans_nid."'")?></td>
            </tr>
            </tbody>
        </table>
    </div>





<?
$repair_list=select_lines_all_items($table_Prefix."repair","","equipmentid = '".$detail['nid']."' order by repairdate desc,nid desc","");?>



    <h2>维修记录</h2>
    <table class="layui-table">
        <colgroup>
            <col width="80">
            <col width="200">
            <col >
            <col>
        </colgroup>
        <thead>
        <tr>
            <th>序号</th>
            <th>维修日期</th>
            <th>维修项目</th>
            <th>维修公司</th>
            <th>金额</th>
            <th>负责人</th>
            <th>归还日期</th>
            <th>状态</th>
            <th>备注</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <?php
        for ($i = 0; $i < count($repair_list); $i++) {
        ?>
        <tr>
            <td><?echo $i+1?></td>
            <td><?echo substr($repair_list[$i]['repairdate'],0,10)?></td>
            <td><?echo $repair_list[$i]['name']?></td>
            <td><?echo $repair_list[$i]['repair_company']?></td>
            <td><?echo $repair_list[$i]['cost']?></td>

            <?$borrower=select_one_line_all_items("user","nid = '".$detail[$i]['borrower']."'");?>

            <td><?echo $borrower["user_name"]?></td>

            <td><?echo substr($repair_list[$i]['returndate'],0,10)?></td>
            <td><?if($repair_list[$i]['status']=="正常"){echo "维修完毕";}else{echo "维修中";}?></td>
            <td><?echo $repair_list[$i]['remark']?></td>
            <td>
                <?if($repair_list[$i]['status']=="维修"){?>
                <a href="../repair/detail-edit.php?nav-itemed=equipment&equipmentid=<? echo $repair_list[$i]['equipmentid']?>&nid=<? echo $repair_list[$i]['nid']?>" class="layui-btn layui-btn-primary layui-btn-small" >
                  <i class="layui-icon">&#xe642;</i>修改
                </a>
            <?}?></td>

        </tr>
        <?;}?>
        </tbody>
    </table>
</div>








</div>

<!--content端點01-->
</div>
<!--maincontent端點01-->
<br class="clearfloat"/>
</div>
<!--container端點01-->
</div>

<?php include '../../modules/footer.php'; ?>
</body>
</html>